home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmigaPlus / Tools / Development / stunnel-4.04 / _src / src / env.c < prev    next >
Encoding:
C/C++ Source or Header  |  2003-01-01  |  2.3 KB  |  62 lines

  1. /*
  2.  *   stunnel       Universal SSL tunnel
  3.  *   Copyright (c) 1998-2003 Michal Trojnara <Michal.Trojnara@mirt.net>
  4.  *                 All Rights Reserved
  5.  *
  6.  *   This program is free software; you can redistribute it and/or modify
  7.  *   it under the terms of the GNU General Public License as published by
  8.  *   the Free Software Foundation; either version 2 of the License, or
  9.  *   (at your option) any later version.
  10.  *
  11.  *   This program is distributed in the hope that it will be useful,
  12.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *   GNU General Public License for more details.
  15.  *
  16.  *   You should have received a copy of the GNU General Public License
  17.  *   along with this program; if not, write to the Free Software
  18.  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  *   In addition, as a special exception, Michal Trojnara gives
  21.  *   permission to link the code of this program with the OpenSSL
  22.  *   library (or with modified versions of OpenSSL that use the same
  23.  *   license as OpenSSL), and distribute linked combinations including
  24.  *   the two.  You must obey the GNU General Public License in all
  25.  *   respects for all of the code used other than OpenSSL.  If you modify
  26.  *   this file, you may extend this exception to your version of the
  27.  *   file, but you are not obligated to do so.  If you do not wish to
  28.  *   do so, delete this exception statement from your version.
  29.  */
  30.  
  31. /* getpeername() can't be declared in the following includes */
  32. #define getpeername no_getpeername
  33. #include <sys/types.h>
  34. #include <sys/socket.h> /* for AF_INET */
  35. #include <netinet/in.h>
  36. #include <arpa/inet.h>  /* for inet_addr() */
  37. #include <stdlib.h>     /* for getenv() */
  38. #ifdef __BEOS__
  39. #include <be/bone/arpa/inet.h> /* for AF_INET */
  40. #include <be/bone/sys/socket.h> /* for AF_INET */
  41. #else
  42. #include <sys/socket.h> /* for AF_INET */
  43. #endif
  44. #undef getpeername
  45.  
  46. int getpeername(int s, struct sockaddr_in *name, int *len) {
  47.     char *value;
  48.  
  49.     name->sin_family=AF_INET;
  50.     if((value=getenv("REMOTE_HOST")))
  51.         name->sin_addr.s_addr=inet_addr(value);
  52.     else
  53.         name->sin_addr.s_addr=htonl(INADDR_ANY);
  54.     if((value=getenv("REMOTE_PORT")))
  55.         name->sin_port=htons(atoi(value));
  56.     else
  57.         name->sin_port=htons(0);
  58.     return 0;
  59. }
  60.  
  61. /* End of env.c */
  62.